<script setup lang="ts">
import { defineProps } from "vue";

defineProps<{
  data: any;
}>();
</script>

<template>
  <div class="overview-cards">
    <el-card shadow="hover" class="card-item">
      <div class="card-content">
        <div class="card-icon ip">
          <el-icon :size="40"><Monitor /></el-icon>
        </div>
        <div class="card-info">
          <div class="card-label">IP总数</div>
          <div class="card-value">{{ data.total_ips || 0 }}</div>
        </div>
      </div>
    </el-card>

    <el-card shadow="hover" class="card-item">
      <div class="card-content">
        <div class="card-icon port">
          <el-icon :size="40"><Connection /></el-icon>
        </div>
        <div class="card-info">
          <div class="card-label">端口总数</div>
          <div class="card-value">{{ data.total_ports || 0 }}</div>
        </div>
      </div>
    </el-card>

    <el-card shadow="hover" class="card-item">
      <div class="card-content">
        <div class="card-icon scanned">
          <el-icon :size="40"><Select /></el-icon>
        </div>
        <div class="card-info">
          <div class="card-label">已扫描IP</div>
          <div class="card-value">{{ data.scanned_ips || 0 }}</div>
          <el-progress
            :percentage="
              data.total_ips
                ? Math.round((data.scanned_ips / data.total_ips) * 100)
                : 0
            "
            :color="'#409EFF'"
          />
        </div>
      </div>
    </el-card>

    <el-card shadow="hover" class="card-item">
      <div class="card-content">
        <div class="card-icon unscanned">
          <el-icon :size="40"><Warning /></el-icon>
        </div>
        <div class="card-info">
          <div class="card-label">未扫描IP</div>
          <div class="card-value">{{ data.unscanned_ips || 0 }}</div>
          <el-progress
            :percentage="
              data.total_ips
                ? Math.round((data.unscanned_ips / data.total_ips) * 100)
                : 0
            "
            :color="'#F56C6C'"
          />
        </div>
      </div>
    </el-card>
  </div>
</template>

<script lang="ts">
import { Monitor, Connection, Select, Warning } from "@element-plus/icons-vue";

export default {
  components: {
    Monitor,
    Connection,
    Select,
    Warning,
  },
};
</script>

<style lang="scss" scoped>
.overview-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.card-item {
  border-left: 4px solid #409eff;
  transition: all 0.3s;

  &:hover {
    border-left-color: #1890ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
}

.card-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.card-icon {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  &.ip {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
  }

  &.port {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
  }

  &.scanned {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
  }

  &.unscanned {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
  }
}

.card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-label {
  font-size: 14px;
  color: #606266;
}

.card-value {
  font-size: 28px;
  font-weight: 600;
  color: #303133;
}

:deep(.el-progress-bar) {
  margin-top: 8px;
}

:deep(.el-progress__text) {
  font-size: 12px;
}
</style>
